﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PointTracker
{
    public partial class Default : System.Web.UI.MasterPage
    {

        private PointTracker.User user = null;
        private UserControl uc;

        protected void Page_Load(object sender, EventArgs e)
        {
            
            user = (PointTracker.User)Session["User"];
            
            if (user == null ){
                user = PointTracker.User.getUserInstance("","");
                uc = (UserControl)Page.LoadControl("/Controls/TopToolBar.ascx");
                panelNav.Visible = false;
            }
            else if(user.role == PointTracker.UserRole.Guest){            
                uc = (UserControl)Page.LoadControl("/Controls/TopToolBar.ascx");
                Session.Add("User", user);                
                panelNav.Visible = false;
            }
            else
            {
                uc = (UserControl)Page.LoadControl("/Controls/TopToolBarLogout.ascx");
                panelNav.Visible = true;
            }
            ContentPlaceHolderTopBar.Controls.Add(uc);
        }
    }
}